#ifndef __LIB_KERNEL_INTR_INIT_H
#define __LIB_KERNEL_INTR_INIT_H


#define SelectorCode32 0x8
#define EFLAGS_IF 0X00000200
#define GET_EFLAGS(EFLAGS_VAR) asm volatile("pushfl; pop %0":"=g"(EFLAGS_VAR)::"memory")
#define INTR_HANDLE_SAVE asm volatile("pusha;\
		push %ds;\
		push %es;\
		push %ss");

#define INTR_HANDLE_RESTORE asm volatile("pop %ss;\
		pop %es;\
		pop %ds;\
		popa;\
		leave;\
		iret");

#define INTR_HANDLE_RESTORE_WITH_ERROR asm volatile("pop %ss;\
		pop %es;\
		pop %ds;\
		popa;\
		addl $4, %esp;\
		leave;\
		iret");

#include "../lib/kernel/io.h"
#include "../lib/stdint.h"


//IdtPtr
typedef struct a 
{
	uint16_t ivt_len;
	uint16_t ivt_base_low16;
	uint16_t ivt_base_high16;
}Idtr;

//Interrupt descriptor.
typedef struct b
{
	uint16_t ihan_low16;
	uint16_t ihan_sel;
	uint16_t iproperty;
	uint16_t ihan_high16;
}Idesc;

enum intr_status {INTR_OFF, INTR_ON};

void intr_init(void);
void pic_init(void);
void en_intr(void);
void enable_intr();
void diable_intr();

#endif